import { handleActions } from 'redux-actions'
import {
  INIT_MAIN_PAGE_C_TYPE,
  UPDATE_MAIN_PAGE_C_TYPE, UPDATE_MY_CENTER_NUMBERS_TYPE, UPDATE_USER_ARCHIVE_EDUCATION_TYPE,
  UPDATE_USER_ARCHIVE_IMG_TYPE,
  UPDATE_USER_ARCHIVE_WORK_TYPE
} from './type'

const Schema = {
  intro: null,
  showEmpty: false,
  networkerror: false,
  archiveInfo: {},
  jobHuntingModels: [],
  userArchiveModel: {},
  userArchiveWorkModels: [],
  userArchiveImgModels: [],
  educations: [],
  myCenterNumbers: {}
}

export default handleActions(
  {
    [INIT_MAIN_PAGE_C_TYPE] (state, action) {
      return {
        ...Schema
      }
    },
    [UPDATE_MAIN_PAGE_C_TYPE] (state, action) {
      return {
        ...state,
        ...action.payload
      }
    },
    [UPDATE_USER_ARCHIVE_EDUCATION_TYPE] (state, action) {
      return {
        ...state,
        ...action.payload
      }
    },
    [UPDATE_USER_ARCHIVE_WORK_TYPE] (state, action) {
      return {
        ...state,
        ...action.payload
      }
    },
    [UPDATE_USER_ARCHIVE_IMG_TYPE] (state, action) {
      return {
        ...state,
        ...action.payload
      }
    },
    [UPDATE_MY_CENTER_NUMBERS_TYPE] (state, action) {
      return {
        ...state,
        ...action.payload
      }
    }
  },
  Schema
)
